<!---选择人员-->
<template>
  <div>

    <el-input v-model="temp.OrgName" prop="OrgName" name="OrgName" :disabled="disabled" @focus="showSelectDialog()" />
    <singlechoicedepartment ref="choicedepartment" :echo-list="checkedData" @submitSelect="selectBack" />
  </div>
</template>
<script>
import singlechoicedepartment from '@/views/components/singlechoicedepartment'
export default {
  components: {
    singlechoicedepartment
  },
  props: {
    data: {
      type: Object,
      default: () => {
        return {}
      }
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dialogVisible: false,
      checkedData: [], // 打开弹窗选择的用户
      temp: this.data || { OrgName: '' }
    }
  },
  watch: {
    data: {
      deep: true,
      handler() {
        if (this.data.Id) {
          this.temp = this.data
        }
      }
    }
  },
  methods: {
    showSelectDialog() {
      this.dialogVisible = true
      if (this.temp.Id) {
        this.checkedData[0] = this.temp
      }
      this.$refs.choicedepartment.showSingleDepartmentDialog()
    },
    // 选择人员时回调方法
    selectBack(taglist) {
      if (taglist != null && taglist.length > 0) {
        this.temp = taglist[0]
      }
      this.$emit('update:data', this.temp)
    }
  }
}
</script>
